#!/usr/bin/python
# Copyright 2011, Kitware, Inc.

import SimpleITK as sitk
import numpy as np

dataDir = '../Data'
image = sitk.ReadImage ( dataDir + '/cthead1.png' )

a = sitk.GetArrayFromImage( image )

h, bins = np.histogram( a, bins=255, range=(0,255) )

mode = 0
for i in range(1, h.shape[0] ):
    if( h[i] > h[mode] ):
        mode = i
print "Mode of image: " + str( mode )
